package stream.Demo01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @Author Miku
 * @Create 2021/4/29 14:09
 * FileInputStream的使用
 * 文件字节输入流
 */
public class Test {
    public static void main(String[] args) throws IOException {
        //1.创建FileInputStream
        FileInputStream fis = new FileInputStream("e:\\aaa.txt");
        //2.1 读取文件
//        int data = 0;
//        while ((data = fis.read()) != -1) {
//            System.out.print((char) data);
//        }
        //2.2 一次读取多个字节
        byte[] bytes = new byte[1024];
        int count = 0;
        while ((count = fis.read(bytes)) != -1) {
            System.out.println(count);
            System.out.println(new String(bytes, 0 ,count));
        }
        //3.关闭
        fis.close();
        System.out.println("执行完毕");



    }
}
